package com.mc.gpm.service.impl;

import java.util.List;
import com.mc.common.utils.DateUtils;
import com.mc.gpm.domain.GpmStorage;
import com.mc.gpm.mapper.GpmStorageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mc.gpm.mapper.GpmInStorageMapper;
import com.mc.gpm.domain.GpmInStorage;
import com.mc.gpm.service.IGpmInStorageService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 种质资源入库Service业务层处理
 *
 * @author mc
 * @date 2021-03-19
 */
@Service
public class GpmInStorageServiceImpl implements IGpmInStorageService
{
    @Autowired
    private GpmInStorageMapper gpmInStorageMapper;
    @Autowired
    private GpmStorageMapper gpmStorageMapper;

    /**
     * 查询种质资源入库
     *
     * @param dtorageId 种质资源入库ID
     * @return 种质资源入库
     */
    @Override
    public GpmInStorage selectGpmInStorageById(String dtorageId)
    {
        return gpmInStorageMapper.selectGpmInStorageById(dtorageId);
    }

    /**
     * 查询种质资源入库列表
     *
     * @param gpmInStorage 种质资源入库
     * @return 种质资源入库
     */
    @Override
    public List<GpmInStorage> selectGpmInStorageList(GpmInStorage gpmInStorage)
    {
        return gpmInStorageMapper.selectGpmInStorageList(gpmInStorage);
    }

    /**
     * 新增种质资源入库
     *
     * @param gpmInStorage 种质资源入库
     * @return 结果
     */
    @Transactional//多次插入开启事务
    @Override
    public int insertGpmInStorage(GpmInStorage gpmInStorage, GpmStorage gpmStorage)
    {
        gpmInStorage.setCreateTime(DateUtils.getNowDate());
        gpmStorageMapper.insertGpmStorage(gpmStorage);
        return gpmInStorageMapper.insertGpmInStorage(gpmInStorage);
    }

    /**
     * 修改种质资源入库
     *
     * @param gpmInStorage 种质资源入库
     * @return 结果
     */
    @Override
    public int updateGpmInStorage(GpmInStorage gpmInStorage)
    {
        return gpmInStorageMapper.updateGpmInStorage(gpmInStorage);
    }

    /**
     * 批量删除种质资源入库
     *
     * @param dtorageIds 需要删除的种质资源入库ID
     * @return 结果
     */
    @Override
    public int deleteGpmInStorageByIds(String[] dtorageIds)
    {
        return gpmInStorageMapper.deleteGpmInStorageByIds(dtorageIds);
    }

    /**
     * 删除种质资源入库信息
     *
     * @param dtorageId 种质资源入库ID
     * @return 结果
     */
    @Override
    public int deleteGpmInStorageById(String dtorageId)
    {
        return gpmInStorageMapper.deleteGpmInStorageById(dtorageId);
    }
}